package com.example.factory.api.controller.scorer;

import com.example.factory.api.dto.*;
import com.example.factory.api.dto.form.DtoReportGardingForm;
import com.example.factory.api.facade.GradingRuleFacade;
import com.example.factory.api.facade.ReportFacade;
import com.example.factory.api.facade.ReporterGradingFacade;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Lei Tao
 */
@RestController
@RequestMapping("/scorer/grading")
public class GradingController {
    private final GradingRuleFacade gradingRuleFacade;
    private final ReporterGradingFacade reporterGradingFacade;
    private final ReportFacade reportFacade;


    public GradingController(GradingRuleFacade gradingRuleFacade, ReporterGradingFacade reporterGradingFacade, ReportFacade reportFacade) {
        this.gradingRuleFacade = gradingRuleFacade;
        this.reporterGradingFacade = reporterGradingFacade;
        this.reportFacade = reportFacade;
    }

    @GetMapping("/level1/list")
    public Response<List<DtoLevel1Dimension>> selectedLevel1Dimensions() {
        return gradingRuleFacade.selectedLevel1Dimensions();
    }

    @GetMapping("/level2/{level1Guid}/list")
    public Response<List<DtoLevel2Dimension>> selectedLevel2Dimensions(@PathVariable("level1Guid")String level1Guid) {
        return gradingRuleFacade.selectedLevel2Dimensions(level1Guid);
    }
    @PostMapping("/save")
    public Response<DtoReportGarding> save(@RequestBody DtoReportGardingForm dtoReportGardingForm){
        return reporterGradingFacade.save(dtoReportGardingForm);
    }
    @GetMapping("/{scorerGuid}/list")
    public Response<List<DtoReport>> list(@PathVariable("scorerGuid") String scorer) {
        return reportFacade.listByScorerGuid(scorer);
    }

    @GetMapping("/{reportGuid}/details")
    public Response<DtoReport> details(@PathVariable("reportGuid") String reportGuid) {
        return reportFacade.details(reportGuid);
    }
}
